<?php
    /**
     * mod_GoogleMap module HOGAS MARIUS
     *
     * @license        GNU/GPL, see LICENSE.php
     * mod_GoogleMap is free software. This version may have been modified pursuant
     * to the GNU General Public License, and as distributed it includes or
     * is derivative of works licensed under the GNU General Public License or
     * other free or open source software licenses.
     */

    defined( '_JEXEC' ) or die( 'Restricted access' );
	$getapps= & JFactory::getApplication();
	$bpath = JURI::base();
	$template = $getapps->getTemplate();
  	$doc =& JFactory::getDocument();

	//Get Values of the parameters
	$height = $params->get('height','');
	$width = $params->get('width','');
	$myLatitude = $params->get('myLatitude','');
	$myLongitude = $params->get('myLongitude','');
	$zoom = $params->get('zoom','');
	$type = $params->get('type','');
	$controll = $params->get('controll','');
	$draging = $params->get('draging','');
	$mousewheel = $params->get('mousewheel','');

	$doc->addScript("http://maps.google.com/maps/api/js?sensor=false");

 	$init = "
	function load() {
	var point = new google.maps.LatLng($myLatitude,$myLongitude);
	
	var myMapOptions = {
		scrollwheel:".(($mousewheel==0) ? 'false' : 'true' ).",
		zoom: $zoom,
		center: point,
		mapTypeControl: true,
		mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.$controll},
		navigationControl: true,
		navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
		mapTypeId: google.maps.MapTypeId.$type
	};
	
	var map = new google.maps.Map(document.getElementById('map'),myMapOptions);
	
	var image = new google.maps.MarkerImage(
	  '$bpath/templates/$template/images/marker-images/image.png',
	  new google.maps.Size(160,90),
	  new google.maps.Point(0,0),
	  new google.maps.Point(85,80)
	);
	
	var shadow = new google.maps.MarkerImage(
	  '$bpath/templates/$template/images/marker-images/shadow.png',
	  new google.maps.Size(220,91),
	  new google.maps.Point(0,0),
	  new google.maps.Point(110,91)
	);
	
	var shape = {
	  coord: [69,0,80,1,84,2,87,3,90,4,93,5,96,6,98,7,100,8,102,9,104,10,105,11,107,12,108,13,110,14,111,15,112,16,113,17,115,18,115,19,117,20,118,21,119,22,120,23,121,24,122,25,123,26,124,27,124,28,125,29,126,30,127,31,127,32,128,33,129,34,129,35,130,36,130,37,131,38,131,39,132,40,132,41,133,42,133,43,133,44,134,45,134,46,135,47,135,48,135,49,136,50,136,51,136,52,136,53,136,54,137,55,137,56,137,57,137,58,137,59,138,60,138,61,138,62,138,63,138,64,138,65,138,66,138,67,138,68,138,69,138,70,138,71,138,72,139,73,139,74,138,75,139,76,139,77,139,78,139,79,138,80,138,81,138,82,138,83,137,84,137,85,137,86,137,87,137,88,136,89,136,90,136,91,135,92,135,93,135,94,134,95,134,96,133,97,133,98,132,99,132,100,131,101,131,102,130,103,130,104,129,105,128,106,128,107,127,108,127,109,126,110,125,111,124,112,124,113,123,114,122,115,122,116,121,117,120,118,119,119,118,120,117,121,116,122,115,123,114,124,113,125,112,126,110,127,109,128,107,129,106,130,103,131,102,132,100,133,99,134,96,135,93,136,89,137,86,138,83,139,79,140,78,141,77,142,76,143,75,144,75,145,74,146,73,147,72,148,71,149,70,150,70,151,70,152,68,152,67,151,67,150,66,149,65,148,64,147,64,146,63,145,62,144,61,143,60,142,60,141,59,140,56,139,52,138,47,137,45,136,43,135,41,134,39,133,37,132,35,131,33,130,32,129,30,128,29,127,28,126,26,125,26,124,24,123,23,122,22,121,21,120,20,119,18,118,18,117,17,116,16,115,15,114,14,113,13,112,13,111,12,110,11,109,11,108,10,107,10,106,9,105,8,104,8,103,7,102,7,101,7,100,6,99,6,98,5,97,5,96,5,95,4,94,4,93,4,92,3,91,3,90,3,89,2,88,2,87,2,86,2,85,2,84,2,83,1,82,1,81,1,80,0,79,0,78,0,77,0,76,0,75,0,74,0,73,0,72,0,71,0,70,0,69,0,68,0,67,0,66,0,65,0,64,0,63,0,62,1,61,1,60,1,59,1,58,1,57,2,56,2,55,2,54,3,53,3,52,3,51,3,50,4,49,4,48,4,47,5,46,5,45,6,44,6,43,7,42,7,41,8,40,8,39,9,38,9,37,10,36,10,35,11,34,11,33,12,32,13,31,14,30,14,29,15,28,16,27,17,26,17,25,18,24,19,23,20,22,21,21,21,20,22,19,24,18,25,17,26,16,27,15,29,14,30,13,31,12,33,11,35,10,36,9,39,8,41,7,43,6,45,5,49,4,53,3,56,2,65,1,69,0,69,0],
	  type: 'poly'
	};
	
	var marker = new google.maps.Marker({
		draggable:".(($draging==0) ? 'false' : 'true' ).",
		raiseOnDrag: false,
		icon: image,
		shadow: shadow,
		shape: shape,
		map: map,
		position: point
		
	});
}
window.addEvent('domready',function() {
	load();
	});
";
$doc->addScriptDeclaration( $init );
$doc->addStyleDeclaration('#rt-showcase .rt-block { height:510px;}');


    echo '<div class="map-wrapper" style="height:'.$height.'px; position:relative;"><div id="map" style="width: '.$width.'px; height:'.$height.'px; margin-left:-'.(($width/2)+10).'px; position:absolute; top:0; left:50%;"></div></div>';
?>